package example;

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService()
public class CalculateService implements ICalculateService{

    @WebMethod
    public double calculate(double salary,double  deduction) {
//        应纳税所得额 = 总收入 - 基本扣除
        double taxableIncome = salary-deduction;
//        税率
        double taxRate = 0;
//        应纳税额
        double output;

//        不同收入对应不同税率
        if (taxableIncome <= 36000) {
            taxRate = 0.03;
        } else if (taxableIncome <= 144000) {
            taxRate = 0.10;
        } else if (taxableIncome <= 300000) {
            taxRate = 0.20;
        } else if (taxableIncome <= 420000) {
            taxRate = 0.25;
        } else if (taxableIncome <= 660000) {
            taxRate = 0.30;
        } else if (taxableIncome <= 960000) {
            taxRate = 0.35;
        } else {
            taxRate = 0.45;
        }

        output = taxableIncome*taxRate;
        return output;
    }
}
